﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.Unity;

namespace ERPStore.FullTextCatalog.Tests
{
	public class Program
	{


		[STAThread]
		public static void Main()
		{
			var container = BootStrapper.InitializeContainer();

			var catalogService = container.Resolve<ERPStore.Services.ICatalogService>();
			var logger = container.Resolve<ERPStore.Logging.ILogger>();
			var searchTermsList = catalogService.GetTopSearchTermList(500);

			foreach (var term in searchTermsList)
			{
				var search = new ERPStore.Models.ProductListFilter()
				{
					Search = term.Name,
				};

				int count = 0;
				logger.Watch("---------------------------", () =>
					{
						var productlist = catalogService.GetProductListBySearch(search, 0, 100, out count);
						var categoryList = catalogService.GetProductCategoryListBySearch(search);
						var brandList = catalogService.GetBrandListBySearch(search);

						Console.WriteLine("Term : {0} => Count Product {1} Category {2} Brand {3}", term.Name, productlist.Count, categoryList.Count, brandList.Count);
					});
			}

			Console.WriteLine("Fin du test");

			GC.Collect();

			Console.ReadKey();
		}
	}
}
